package com.goldplusgold.network.lib;

import android.content.Context;

import java.util.HashMap;

/**
 */
public class AppCollectedInfoUtil {


    private static Object sCommonParamLocker = new Object();
    public static HashMap<String, String> sArrayNameValuePair = new HashMap<>();
    public static HashMap<String, String> sArrayNameValuePairEncode = new HashMap<>();
    public static Context mContext;


    public static boolean initAppCollectedInfo(Context ctx, String token, String time, String versionName) {
        if (mContext == null) {
            mContext = ctx.getApplicationContext();
        }

        synchronized (sCommonParamLocker) {
            sArrayNameValuePair.clear();
            sArrayNameValuePairEncode.clear();

            sArrayNameValuePair.put("Authorization", "Bearer " + token);
            sArrayNameValuePairEncode.put("Authorization", "Bearer " + token);

            sArrayNameValuePair.put("_platform", "android");
            sArrayNameValuePairEncode.put("_platform", "android");

            sArrayNameValuePair.put("jzjLoginTime", time);
            sArrayNameValuePairEncode.put("jzjLoginTime", time);

            sArrayNameValuePair.put("_version", versionName);
            sArrayNameValuePairEncode.put("_version", versionName);
        }

        return true;
    }

    public static HashMap<String, String> getAppDefaultParams(boolean isNeedEncode) {
        synchronized (sCommonParamLocker) {
            if (isNeedEncode) {
                return sArrayNameValuePairEncode;
            } else {
                return sArrayNameValuePair;
            }
        }
    }

}
